<?php 
class StorelistController extends CommonController{

		public $model;

		public function __init(){
			$this->model = K('store');
		}
		
		public function index(){


			// 商铺的stid
			$cnid = Q('get.cnid',NULL,'intval');

			// $Storedata = K('StoreTagView')->get_data('store.stid');
			
			// P($Storedata);
			
			$where = '';
			$attr = Q('get.s');
			$attr = explode(',',rtrim($attr,','));

			// $newAttr = array();
			// foreach ($s as $value) {
			// 	if($value=='piao'){
			// 		$value='票';
			// 	}else if($value=='mian'){
			// 		$value='免';
			// 	}else if($value=='jian'){
			// 		$value='减';
			// 	}
			// 	$newAttr[] = $value;
			// }

			// $newStr = implode(',', $newAttr);
			if($attr){
				foreach ($attr as $value) {
					$where .='favorable like "%'.$value.'%" AND ';
				}
			}
		
		
			if(empty($cnid)){
				if (empty($attr)) {
				$Storedata =  $this->model->all();
				}else{
				$Storedata =  $this->model->where($where)->all();

				}
				
			}else{
				if(empty($attr)){
				$Storedata =  $this->model->where(array('cnid'=>$cnid))->all();
				}else{
				$Storedata =  $this->model->where(array('cnid'=>$cnid,$where))->all();
				
				}	
			}
			
			
			
			$this->assign('Storedata',$Storedata);


		

			$this->display();
		}


}




 ?>